package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.DisasterPrevention.ClassBean;
import com.project.service.IClassService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("cls")
public class ClassController {

    @Resource
    private IClassService classService;

    @RequestMapping("findCutClass")
    public IPage<ClassBean> findCutClass(@RequestParam(value = "pageNo",defaultValue = "1") int pageNo, @RequestParam(value = "pageSize",defaultValue = "3") int pageSize, String className, String regionName){

        IPage<ClassBean> page = classService.findCutClass(pageNo,pageSize,className,regionName);


        return page;
    }


    @RequestMapping("addClass")
    public String addClass(ClassBean classBean) {

        if (classBean != null){
            classService.addClass(classBean);
        }

        return "ok";
    }

    @RequestMapping("findClass")
    public ClassBean findClass(int classId) {

        ClassBean classBean = classService.findClass(classId);

        return classBean;
    }

    @RequestMapping("updateClass")
    public String updateClass(int classId, String classPerson,String classPersonTel) {

        classService.updateClass(classId,classPerson,classPersonTel);

        return "ok";
    }

    @RequestMapping("findAllCls")
    public List<ClassBean> findAllCls(){

       return   classService.findAllCls();

    }


}
